{% set lvars = { 'host_ip' : '192.168.122.1', 'pxe_network' : False} %}
{% for network in networks %}
{% if (not (network.forward_mode is defined and network.forward_mode == 'nat') and lvars['pxe_network'] == False) %}
{% if lvars.update({'pxe_network' : network.name}) %}{% endif %}
{% endif %}
{% if network.address is defined and lvars['host_ip'] == '192.168.122.1' %}
{% if lvars.update({'host_ip' : network.address}) %}{% endif %}
{% endif %}
{% endfor %}
{
  "nodes": [
  {% for node in overcloud_nodes %}
    {
      "name": "{{ node.name|replace('_', '-') }}",
      {% if release in ['newton'] %}
        "pm_password": {{ virt_power_key_pvt | to_nice_json }},
        "pm_type": "pxe_ssh",
        "pm_user": "{{ ansible_user_id }}",
        "pm_addr": "{{ lvars['host_ip'] }}",
      {% else %}
        "pm_password": "password",
        {% if release == 'ocata' %}
          "pm_type": "pxe_ipmitool",
        {% else %}
          "pm_type": "ipmi",
        {% endif %}
        "pm_user": "admin",
        "pm_addr": "{{ undercloud_local_ip|default(undercloud_network_cidr)|nthhost(1) }}",
        "pm_port": "{{ node.virtualbmc_port }}",
      {% endif %}
      {% if release not in ['queens', 'stein', 'train', 'ussuri', 'victoria', 'wallaby'] %}
        "ports": [
          {"address": "{{ node_mac_map.get(node.name).get(lvars['pxe_network']) }}"}
        ],
      {% else %}
        "mac": [
          "{{ node_mac_map.get(node.name).get(lvars['pxe_network']) }}"
        ],
      {% endif %}
      "cpu": "{{ flavors[node.flavor].vcpu }}",
      "memory": "{{ flavors[node.flavor].memory }}",
      "disk": "{{ flavors[node.flavor].disk }}",
      "arch": "{{ libvirt_arch }}",
      "capabilities": "profile:{{ node.flavor }},boot_option:local,boot_mode:{{ libvirt_boot_mode }}",
      "root_device": { "name": "/dev/{{ libvirt_diskdev }}" }
    }
    {% if not loop.last %}
    ,
    {% endif %}
  {% endfor %}
  ]
}
